
// import {getAddressCode,getAddressText,VAccountpwd,elmessage,data} from "@/hook/hook"

import { identity } from '@vueuse/shared'
import { CodeToText, TextToCode } from 'element-china-area-data'
import { ElMessage } from "element-plus"



// 岗位状态标签颜色
export const ElTagState = (str: string) => {
  if (str == "已通过" ||str ==  "正在招聘") {
    return "success"
  } else if (str == "未通过" ||str ==  "已被撤销" ||str ==  "已停止招聘") {
    return "danger"
  } else {
    return "warning"
  }
}

// 将地区名称转换成地区代码

export const formatDate=()=> {  
  const now=new Date()
  var year=now.getFullYear(); 
  var month=(now.getMonth()+1).toString(); 
  var date=(now.getDate()).toString(); 
  var hour=(now.getHours()).toString(); 
  var minute=(now.getMinutes()).toString(); 
  var second=(now.getSeconds()).toString(); 
  if (month.length<2){
    month="0"+month
  }
  if (date.length<2){
    date="0"+date
  }
  if (hour.length<2){
    hour="0"+hour
  }
  if (minute.length<2){
    minute="0"+minute
  }
  if (second.length<2){
    second="0"+second
  }
  return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; 

}

export function getAddressCode(addressTextArr: Array<string>) {
  
  if (addressTextArr[0] === "全国地区不限" || addressTextArr[0] === "") {
    return ["", ""]
  } else {
    if (addressTextArr[1] === "") {
      return [TextToCode[addressTextArr[0]].code, ""]
    } else {
      return [TextToCode[addressTextArr[0]].code, TextToCode[addressTextArr[0]][addressTextArr[1]].code]
    }
  }
}
// 将地区代码转换成地区名称
export function getAddressText(addressCodeArr: Array<string>) {

  if (addressCodeArr[0] == "全部" || addressCodeArr[0] == "") {
    return ["全国地区不限", ""]

  } else {
    if (addressCodeArr[1] === "") {
      return [CodeToText[addressCodeArr[0]], ""]
    } else {
      return [CodeToText[addressCodeArr[0]], CodeToText[addressCodeArr[1]]]
    }
  }


}
// 修改密码
export function VAccountpwd(accountFrom: any) {
  if (accountFrom.email == "a@a.com" && accountFrom.password == "123456") {
    return true
  } else {
    return false
  }
}

export function elmessage(message: string, type: any) {
  // type: 'success' | 'warning' | 'info' | 'error'
  ElMessage({
    showClose: true,
    message: message,
    type: type,
    duration: 1000
  })
}


export const data = () => {
  const data = {
    loginId: localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").loginId : null,
    identity: localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").identity : null,
    token: localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").token : null,
  }
  return data
}
// const headerData={
//   loginId:"",
//   identity:"",
//   token:"",
// }

// const getLoginId=()=>{
//   return headerData.loginId
// }
// const setLoginId=()=>{
//   headerData.loginId=localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").loginId : null
// }




// export const data={
//   loginId: localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").loginId : null,
//   identity: localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").identity : null,
//   token: localStorage.getItem("loginData") ? JSON.parse(localStorage.getItem("loginData") || "").token : null,
// }
